home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-03-10 | 8.5 KB | 315 lines | [TEXT/MPS ] |
-
- PCCTS 1.31 Release Notes
-
- Active Authors for 1.31 Release:
-
- Terence Parr
- Parr Research Corporation
- 5517 Pleasant Ave
- Minneapolis, MN 55419
- parrt@acm.org
-
- Russell W. Quong
- School of Electrical Engineering
- Purdue University
- W. Lafayette, IN 47907
- quong@ecn.purdue.edu
-
- Other authors:
-
- Will Cohen, cohenw@ecn.purdue.edu
- Hank Dietz, hankd@ecn.purdue.edu
-
- January 1, 1995
-
-
- This document describes the 1.31 release of the Purdue Compiler
- Construction Tool Set (PCCTS). This file describes the changes
- made to PCCTS 1.30 to arrive at PCCTS 1.31. No major new
- features were added, but lots of bug fixes were made. The
- original 1.00 manual and all release notes are required for a
- complete documentation set for PCCTS. A book is in the works and
- the papers provided at the ftp site don't hurt.
-
- PCCTS is in the public-domain and can be obtained at
- everest.ee.umn.edu in pub/pccts/1.31. The newsgroup
- comp.compilers.tools.pccts provides a discussion forum. To
- receive future release broadcast messages, register yourself by
- sending email to pccts@ecn.purdue.edu with a ``Subject:'' line of
- ``register''. The WWW site is ``http://tempest.ecn.purdue.edu:8001/''
-
- The authors make no claims that this software will do what you
- want, that this manual is any good, or that the software actually
- works---use PCCTS at your own risk. Bug reports and/or cheery
- reports of its usefulness are very welcome, however.
-
- The maintenance and support of all PCCTS tools is primarily
- provided by Parr Research Corporation, Minneapolis MN. Please see
- file PCCTS.FUTURE for more information. All PCCTS tools currently
- in the public domain will continue to be in the public domain.
-
-
-
- I. NEW FEATURE
-
- [Exception handling is still considered ALPHA quality--meaning that
- things could change in the future.]
-
- [Yes, we know that the '@' char is a hideous choice of operator
- symbols, but we had no other free symbols--TJP]
-
- As a result of Terence's trip to NeXT in November, the parser
- exception handling has been proven a useful mechanism. Our
- preliminary results indicate that error reporting is good and error
- recovery is as good or better than a hand-built parser. However, the
- mechanism, as defined in the 1.30 release notes, was a bit unwieldy
- for the more common errors. For example, given the grammar
-
- start : A B ;
-
- the programmer could generate exceptions to handle the cases where 'A'
- or 'B' were missing:
-
- start : A B ;
- exception
- catch MismatchedToken : <</* error: missing token */>>
-
- However, this approach would require that a similar exception be
- written for each alternative in the grammar that required missing
- tokens to be trapped LOCALLY--that is, handled immediately without
- throwing an exception to the calling rule.
-
- BASIC IDEA
-
- The programmer may suffix any token reference with the '@' operator;
- this indicates that if that token is not seen on the input stream,
- errors are to be handled immediately. In particular, [for the moment]
- the function zzmatch_wdfltsig() or zzsetmatch_wdfltsig() is called in
- C and C++ mode. We anticipate making these routines call the
- default/global handler specified by the user; i.e.,
-
- <<
- main() {...}
- >>
- exception
- catch MismatchedToken : <<my default handler>> // FUTURE!!!
-
- a : ... ;
-
- rather than having the user redefine these functions if necessary.
- The behavior of these routines upon an error is to print out an error
- message:
-
- line 1: syntax error at "blah" missing BLECH
-
- and then consumes input until a token is found that can possibly
- follow that token reference. For example,
-
- a : A@ stat ;
- stat : B | C ;
-
- If 'A' is missing on the input stream, an error message would be
- printed and the parser would consume tokens until either a 'B' or a
- 'C' was seen.
-
- SHORTHAND
-
- The user may suffix the rule definition:
-
- a@ : ... ;
-
- or the '|' in an alternative definition:
-
- a :@ ...
- |@ ...
- ;
-
- as a shorthand for placing an '@' after each token reference.
-
- MORE FUNCTIONALITY INFO
-
- Let's look at the functionality of the following grammar fragment:
-
- stat : "if" expr "then"@ stat { "else"@ stat }
- |@ u:ID "=" expr ";"
- ;
- exception
- catch NoViableAlt : <</* bad or missing stat */>>
-
- The behavior is summarized in the following table:
-
- INPUT ACTION EXECUTED
- ; /* bad or missing stat */
- = /* bad or missing stat */
- if 1 a=b; match_wdfltsig(THEN) catches the missing 'then'; prints msg
- and recovers by consuming until it finds an 'if' or an ID.
- a 3; match_wdfltsig("=") catches the missing '='; prints msg
- and recovers by consuming until it finds the first symbol
- of a valid expr.
-
- REAL EXAMPLE
-
- Given input
-
- a = b;
- B
-
- this example will print
-
- line 1: syntax error at "a" missing BEGIN
- found assignment to a
-
- Given input
-
- a b;
- B
-
- the output will be
-
- line 2: syntax error at "b" missing =
- found assignment to a
-
- Given input
-
- A
- if a+ then a=b;
-
- the output will be
-
- invalid conditional in 'if' statement
- found assignment to a
-
- Given input
-
- A =
-
- the output will be
-
- uncaught exception
-
- ----------------
- #header <<#include "charbuf.h">>
-
- <<
- main()
- {
- int signal;
- ANTLR(rule(&signal), stdin);
- if ( signal ) fprintf(stderr, "uncaught exception\n");
- }
- >>
-
- #token "[\ \t]+" <<zzskip();>>
- #token "\n" <<zzskip(); zzline++;>>
- #token THEN "then"
- #tokclass DIE { "@" "if" ID "else" }
- #tokclass BEGIN { "A" "B" }
-
- rule: BEGIN@
- ( stat )+
- "end"@
- ;
-
- stat: "if" t:expr "then"@ stat { "else"@ stat }
- |@ u:ID "=" expr ";"
- <<printf("found assignment to %s\n", $u.text);>>
- ;
- exception[t]
- default :
- <<
- printf("invalid conditional in 'if' statement\n");
- zzconsumeUntilToken(THEN);
- >>
-
- expr: expr1 ("\+" expr1)*
- ;
-
- expr1
- : expr2 ("\*" expr2)*
- ;
-
- expr2: ID
- ;
-
- #token ID "[a-z]+"
- ----------------
-
-
- II. CHANGES AND BUG FIXES
-
- o genmk was changed to use .o (see config.h) rather than .$(OBJEXT);
- the result is a much cleaner makefile.
-
- o Added a 'typedef int TokenType;' in antlr.h (not that I change
- all the 'int's everywhere in the output <wink>).
-
- o Fixed bug in testcpp/7 for ANTLR (didn't compute result correctly).
-
- o Added the '@' operator for exception handling
-
- o Fixed a few code gen bugs relating to exception handling: extra commas
- and extra default clauses, etc...
-
- o Fixed demand lookahead in C++. Kudos to Grant M. Gibson
- gibson@sunquest.sunquest.com.
-
- o Fixed erroneous warnings concerning labels that were defined correctly.
-
- o ANTLR now allows "#ifndef" gates in #tokdef files
-
- o The prototype for zzdflthandler was wrong (had only one arg).
-
- o ANTLR forgot to ignore #if as a preprocessor symbol. It thought it
- was a tree label reference. E.g.,
-
- #if defined(MAIN)
-
- got transformed into:
-
- if_ast defined(MAIN)
-
- o The wildcard mechanism was seriously hosed (ANTLR core-dumped).
-
- o DLG was closing a file more than once in main.c
-
- o Created NOTES.watcom for WATCOM 32bit C because its different than
- other PC compilers.
-
- o The file dlgauto.h still had a __STDC__ instead of __USE_PROTOS guard.
-
- o Fixed a few bugs in preorder() and destroy() in ASTBase.C
-
- o I moved the definition of zzEOF_TOKEN (for C mode) into tokens.h
- rather than having it defined in every file.
-
- o A bitset in the ANTLR output called 'WildCard_set' is available
- (representing all valid token types) if '.' wildcard operator used
- anywhere.
-
- o The syn() is now virtual in C++ mode so you can redefine it more
- easily.
-
-
- III. A FEW KNOWN BUGS
-
- o I would like to make an auto test script for the C++ samples to
- check their input/output.
-
- o FOLLOW(rule) and FIRST(rule) capabilities need to be added to the
- tokclass declaration.
-
- o No warning is given for nonstandard signals used in parser exception
- handling.
-
- o Nothing has been done about the failure of semantic predicates
- with regards to exception handling.
-
- o No warning is given if all alts of a block are guesses: (...)?.
-
-
- IV. ACKNOWLEDGEMENTS
-
- The usual culprits: all those who have been hammering away on ANTLR.
- We thank NeXT (Sumana Srinivasan and Mike Monegan) again for helping
- to shape the exception handling '@' operator.
-